package com.micro.ai.template.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * 工作流执行实体
 *
 * @author micro-ai
 * @since 0.0.1
 */
@Data
@TableName(value = "workflow_executions", autoResultMap = true)
@Schema(description = "工作流执行")
public class WorkflowExecution {

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Schema(description = "主键ID")
    private String id;

    @TableField("execution_id")
    @Schema(description = "执行ID")
    private String executionId;

    @TableField("workflow_id")
    @Schema(description = "工作流ID")
    private String workflowId;

    @TableField(value = "input_data", typeHandler = JacksonTypeHandler.class)
    @Schema(description = "输入数据")
    private Map<String, Object> inputData;

    @TableField(value = "output_data", typeHandler = JacksonTypeHandler.class)
    @Schema(description = "输出数据")
    private Map<String, Object> outputData;

    @TableField("status")
    @Schema(description = "状态(RUNNING/COMPLETED/FAILED/CANCELLED)")
    private String status;

    @TableField("current_step")
    @Schema(description = "当前步骤")
    private Integer currentStep;

    @TableField("total_steps")
    @Schema(description = "总步骤数")
    private Integer totalSteps;

    @TableField("error_message")
    @Schema(description = "错误信息")
    private String errorMessage;

    @TableField("execution_time_ms")
    @Schema(description = "执行时间(毫秒)")
    private Integer executionTimeMs;

    @TableField("started_by")
    @Schema(description = "启动者")
    private String startedBy;

    @TableField("created_at")
    @Schema(description = "创建时间")
    private LocalDateTime createdAt;

    @TableField("completed_at")
    @Schema(description = "完成时间")
    private LocalDateTime completedAt;
}

